﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyDMS.BusinessLayer;

public partial class UserRoles : PageBaseClass
{
    UserRoleFactory urFactory;
    protected void Page_Load(object sender, EventArgs e)
    {
        urFactory = new UserRoleFactory();
        List<UserRole> userRoles = urFactory.GetAllBy(UserRole.UserRoleFields.Office_Code, _author.office_Code);
        this.gvUserRoles.DataSource = userRoles;
        this.gvUserRoles.DataBind();
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        UserRole uRole = new UserRole();
        uRole.Role_Name = txtRoleName.Text;
        uRole.Role_Description = txtDescription.Text;
        uRole.Office_Code = _author.office_Code;

        urFactory = new UserRoleFactory();
        if (urFactory.Insert(uRole))
        {
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Error!";
        }
        lblMessage.Visible = true;
    }
}
